package com.feijin.testwisdomzonedemo.util.base;

import com.feijin.testwisdomzonedemo.actions.BaseAction;
import com.lgc.garylianglib.util.L;
import com.lgc.garylianglib.util.base.BaseActivity;

import butterknife.ButterKnife;

/**
 * <pre>
 *     author : feijin_lgc
 *     e-mail : 595184932@qq.com
 *     time   : 2018/2/24 18:11
 *     desc   :
 *     version: 1.0
 * </pre>
 */
public abstract class UserBaseActivity<P extends BaseAction> extends BaseActivity implements BaseAction.NoLoginListener {

    protected P baseAction;

    protected abstract P initAction();

    protected abstract void initialize();

    protected void binding(int layoutId) {
        setContentView(layoutId);
        ButterKnife.bind(this);
        baseAction = initAction();
        initialize();
        if (baseAction != null) {

            baseAction.setNoLoginListener(this);
        }
    }

    @Override
    public void finish() {
        super.finish();
        if (baseAction != null) {

            baseAction.setNoLoginListener(null);
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (baseAction != null) {
            baseAction.unregister();
            baseAction.dettachView();
        }

    }

    @Override
    public void tologin() {
        L.e("xx", "要去登录了，已经过期.....");
    }


//    protected void pauseGlide() {
//        GlideApp.with(MyApplication.getInstance()).pauseRequests();
//    }

}
